<!-------------------------------------
ページ名：index.jsp
所　　属：H3A1 04
名　　前：大瀬碩
説　　明：ポータルトップページ
--------------------------------------->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import= "java.text.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<title>ポータルトップ</title>
</head>
<body style="font-size: large">
	<!-- ロゴ表示 -->
	<h1 align="center"><img alt="" src="images/logo.png" style="height: 190px;"></h1>
	
	<!-- 学校からのお知らせ表示 -->
	<div class="container well" align="center">
		<%
		out.println("<h2><u>学校からのお知らせ</u></h2>");
		try{
			ServletContext context = this.getServletContext();
			String path = context.getRealPath("/WEB-INF/connect.properties");
			
			InputStream in = new FileInputStream(path);
			Properties properties = new Properties();
			properties.load(in);
			in.close();
			
			Class.forName("com.mysql.jdbc.Driver");
			Connection conn = null;
			String url = properties.getProperty("key1");
			String user = properties.getProperty("key2");
			String password = properties.getProperty("key3");
			conn = DriverManager.getConnection(url, user, password);
			Statement stmt = conn.createStatement();
			String sql = "SELECT * FROM oshirase";
			ResultSet rs = stmt.executeQuery(sql);
			
			while(rs.next()){
				out.print("<p align=\"center\"><font size=\"5\">"+rs.getString("message")+"</font></p>");
			}
			
			rs.close();
			stmt.close();
			conn.close();
		}
		catch (ClassNotFoundException e){
			
		}
		catch (SQLException e){
			
		}
		catch (Exception e){
			
		}
		%>
	</div>
	
	<!-- 機能ボタン表示 -->
	<div class="container" align="center">
		<div class="btn-toolber" align="center">
			<a class="btn btn-lg btn-primary" href="TimetableClassSelection.jsp"><i class="glyphicon glyphicon-th-large" title="時間割を表示することができます"><br><font size="5">時間割表示</font></i></a>
			<a class="btn btn-lg btn-primary" href="ClubList.jsp"><i class="glyphicon glyphicon-flag" title="部活動の情報を表示することができます"><br><font size="5">部活動情報表示</font></i></a>
			<%
			HttpSession ses = request.getSession(true);
			
			Object login = ses.getAttribute("login");
			
			if ("OK".equals(login)){
				out.println("<a class=\"btn btn-lg btn-primary\" href=\"SupplementaryClasses.jsp\" ><i class=\"glyphicon glyphicon-file\" title=\"振り替え補講の申請を行うことができます\"><br><font size=\"5\">振り替え補講申請</font></i></a>");
				out.println("<a class=\"btn btn-lg btn-primary\" href=\"HolidayAttendance.jsp\"><i class=\"glyphicon glyphicon-hand-up\" title=\"土日出校の申請を行うことができます\"><br><font size=\"5\">土日出校申請</font></i></a>");
				out.println("<a class=\"btn btn-lg btn-primary\" href=\"AttendanceHistory.jsp\"><i class=\"glyphicon glyphicon-list-alt\" title=\"出席履歴の表示を行います\"><br><font size=\"5\">出席履歴</font></i></a>");
			}else{
				out.println("<a class=\"btn btn-lg btn-primary\" disabled><i class=\"glyphicon glyphicon-file\" title=\"未ログイン時は利用することができません\"><br><font size=\"5\">振り替え補講申請</font></i></a>");
				out.println("<a class=\"btn btn-lg btn-primary\" disabled><i class=\"glyphicon glyphicon-hand-up\" title=\"未ログイン時は利用することができません\"><br><font size=\"5\">土日出校申請</font></i></a>");
				out.println("<a class=\"btn btn-lg btn-primary\" disabled><i class=\"glyphicon glyphicon-list-alt\" title=\"未ログイン時は利用することができません\"><br><font size=\"5\">出席履歴</font></i></a>");
			}
			%>
		</div>
		
		<br>
		<!-- 個人の情報とお知らせ表示 -->
		<%
		Calendar Cal = new GregorianCalendar(new Locale("ja","JP"));
		Calendar Cal2 = new GregorianCalendar(new Locale("ja","JP"));
		Cal.setTime(new java.util.Date());
		Cal2.setTime(new java.util.Date());
		SimpleDateFormat DF = new SimpleDateFormat("yyyy/MM/dd");
		Cal2.add(Calendar.DATE,-7);
		
		if("OK".equals(login)){
			Object id = ses.getAttribute("id");
			Object name = ses.getAttribute("name");
			Object class_id = ses.getAttribute("class");
			Object a_number = ses.getAttribute("a_number");
			Object club = ses.getAttribute("club");
			int captain = (Integer)ses.getAttribute("captain");
			int s_captain = (Integer)ses.getAttribute("s_captain");
			String cap = "";
			String class_index = null;
			String club_index = null;
			int i = 0;
			int j = 0;
			String ad1 = null;
			String ad2 = null;
			String ds1 = null;
			String ds2 = null;
			
			if(captain == 1){
				cap = "キャプテン";
			}
			
			if(s_captain == 1){
				cap = "副キャプテン";
			}
			
			try{
				ServletContext context = this.getServletContext();
				String path = context.getRealPath("/WEB-INF/connect.properties");
				
				InputStream in = new FileInputStream(path);
				Properties properties = new Properties();
				properties.load(in);
				in.close();
				
				Class.forName("com.mysql.jdbc.Driver");
				Connection conn = null;
				String url = properties.getProperty("key1");
				String user = properties.getProperty("key2");
				String password = properties.getProperty("key3");
				conn = DriverManager.getConnection(url, user, password);
				Statement stmt = conn.createStatement();
				String sql = "SELECT * FROM class,club WHERE  class_id = "+class_id+
				" AND club_id = "+club;
				ResultSet rs = stmt.executeQuery(sql);
				while(rs.next()){
					class_index = rs.getString("class_name");
					club_index = rs.getString("club_name");
				}
				
				out.println("<div class=\"container\" align=\"center\">");
				out.println("<div class=\"col-md-6 col-md-offset-3 well\" align=\"center\">");
				out.println("<h1>ようこそ</h1>");
				out.println("<p align=\"center\"><font size=\"4\">"+class_index+"　出席番号"+a_number+"番　"+name+"さん</font></p>");
				out.println("<p align=\"center\"><font size=\"4\">"+club_index+"所属　"+cap+"</font></p>");
				out.println("<br>");
				out.println("<h2><u>あなたへのお知らせ</u></h2>");
				
				sql = "SELECT * FROM weekend_reservation WHERE decision_date BETWEEN '"+DF.format(Cal2.getTime())+"' AND '"+DF.format(Cal.getTime())+"'"+
				" AND student_id = "+id;
				rs = stmt.executeQuery(sql);
				while(rs.next()){
					i = rs.getInt("decision_flag");
					ad1 = rs.getString("application_date");
					ad2 = rs.getString("decision_date");
					if(i == 1){
						out.print("<p align=\"center\"><font size=\"4\">"+ad1+"に申請した土日出校申請は"+ad2+"に承認されました</font></p>");
					}
					if(i == 2){
						out.print("<p align=\"center\"><font size=\"4\">"+ad1+"に申請した土日出校申請は"+ad2+"に拒否されました</font></p>");
					}
				}
				
				sql = "SELECT * FROM makeup_class WHERE acceptance_date BETWEEN '"+DF.format(Cal2.getTime())+"' AND '"+DF.format(Cal.getTime())+"'"+
				" AND student_id = "+id;
				rs = stmt.executeQuery(sql);
				while(rs.next()){
					j = rs.getInt("acceptance_flag");
					ds1 = rs.getString("date_and_supplementary");
					ds2 = rs.getString("acceptance_date");
					if(j != 0){
						out.print("<p align=\"center\"><font size=\"4\">"+ds1+"に申請した振り替え補講は"+ds2+"に承認されました</font></p>");
					}
					if(j == 0){
						out.print("<p align=\"center\"><font size=\"4\">"+ds1+"に申請した振り替え補講は"+ds2+"に拒否されました</font></p>");
					}
				}
				
				out.println("</div>");
				out.println("</div>");
				
				rs.close();
				stmt.close();
				conn.close();
			}
			catch (ClassNotFoundException e){
			}
			catch (SQLException e){
			}
			catch (Exception e){
			}
		}
		%>
		
		<!-- ログイン・ログアウトボタンの表示 -->
		<%
		if ("OK".equals(login)){
			out.print("<a class=\"btn btn-lg btn-danger\" href=\""+request.getContextPath()+"/Logout\"><i class=\"glyphicon glyphicon-off\"><br><font size=\"5\">ログアウト</font></i></a>");
		}else{
			out.print("<a class=\"btn btn-lg btn-success\" href=\"Login.jsp\"><i class=\"glyphicon glyphicon-off\"><br><font size=\"5\">ログイン</font></i></a>");
		}
		%>
	</div>
		
	<br>
	
	<!-- リンク集とニュースの表示 -->
	<div class="container" align="center">
		<div class="row">
			<div class="col-md-3" align="center">
				<table class="table table-hover">
					<tr><th>リンク</th></tr>
					<tr><td><a href="http://www.jitec.jp/">情報処理技術者試験センター</a></td></tr>
					<tr><td><a href="http://jken.sgec.or.jp/index.html">情報処理活用能力検定(J検)</a>  <a href="jken/">過去問題</a></td></tr>
					<tr><td><a href="http://bken.sgec.or.jp/index.html">ビジネス能力検定(B検)</a>  <a href="bken/">過去問題</a></td></tr>
					<tr><td><a href="http://www.cgarts.or.jp/kentei/">CG/MM検定</a>  <a href="mm/">過去問題</a></td></tr>
					<tr><td><a href="http://www.kentei.ne.jp/bookkeeping/">日本商工会議所 簿記検定</a></td></tr>
					<tr><td><a href="http://www.kentei.ne.jp/retailsales/">日本商工会議所 販売士検定</a></td></tr>
					<tr><td><a href="http://www.jami.jp/hcit/HCIT_SITES/index.php">医療情報技師育成部会</a></td></tr>
					<tr><td><a href="http://www.oracle.com/global/jp/education/certification/portal/index.html">Oracle Master</a></td></tr>
					<tr><td><a href="http://biz.ocn.ne.jp/master/">.com Master</a></td></tr>
					<tr><td><a href="http://jp.sun.com/training/certification/index.xml">Sun Java 認定資格</a></td></tr>
					<tr><td><a href="http://www.umlcert.org/">OMG認定 UML技術者資格試験</a></td></tr>
					<tr><td><a href="http://www.lpi.or.jp/lpic/aboutlpic/index.shtml">LPI認定試験（LPIC：<BR>Linux Professional Institute Certified）</a></td></tr>
					<tr><td><a href="http://www.prometric-jp.com/">プロメトリック</a></td></tr>
					<tr><td><a href="http://www.pearsonvue.com/japan/index.html">ピアソンVUE</a></td></tr>
				</table>
			</div>
			
			<div class="col-md-3 col-md-offset-1" align="center">
				<table class="table">
					<tr><th>ニュース</th></tr>
					<tr><td>
					<!-- start feedwind code -->
					<script type="text/javascript">
					<!--
					rssmikle_url="http://headlines.yahoo.co.jp/rss/cnetj-c_sci.xml";
					rssmikle_frame_width="250";
					rssmikle_frame_height="650";
					rssmikle_target="_blank";
					rssmikle_font="'メイリオ','ＭＳ Ｐゴシック',sans-serif";
					rssmikle_font_size="12";
					rssmikle_border="off";
					rssmikle_css_url="";
					autoscroll="on";
					scrollstep="3";
					mcspeed="20";
					sort="New";
					rssmikle_title="off";
					rssmikle_title_bgcolor="#9ACD32";
					rssmikle_title_color="#FFFFFF";
					rssmikle_title_bgimage="http://";
					rssmikle_item_bgcolor="#FFFFFF";
					rssmikle_item_bgimage="http://";
					rssmikle_item_title_length="55";
					rssmikle_item_title_color="#666666";
					rssmikle_item_border_bottom="on";
					rssmikle_item_description="on";
					rssmikle_item_description_length="150";
					rssmikle_item_description_color="#666666";
					rssmikle_item_date="off";
					rssmikle_timezone="no";
					rssmikle_item_description_tag="off";
					rssmikle_item_podcast="off";
					//-->
					</script>
					<script type="text/javascript" src="http://widget.feed.mikle.com/js/rssmikle.js"></script>
					<div style="font-size:10px; text-align:right;">
					<a href="http://feed.mikle.com/" target="_blank" style="color:#CCCCCC;">RSS widget</a>
					<!--Please display the above link in your web page according to Terms of Service.-->
					</div>
					<!-- end feedwind code -->
					</td></tr>
				</table>
			</div>
			
			<div class="col-md-3 col-md-offset-1" align="center">
				<table class="table table-hover">
					<tr><th>学生お勧めサイト</th></tr>
					<tr><td><a href="http://www.hottomotto.com/menu/list/index.php?id=22">ほっともっと,Hotto Motto亭</a></td></tr>
					<tr><td><a href="http://www.mbc.co.jp/weather/">MBC気象情報</a></td></tr>
					<tr><td><a href="http://www.asahi.com/">朝日新聞</a></td></tr>
					<tr><td><a href="http://www.iajapan.org/rule/">NETルール&amp;マナー集</a></td></tr>
					<tr><td><a href="http://e-words.jp/">e-Words</a></td></tr>
					<tr><td><a href="http://www.javadrive.jp/">JavaDrive</a></td></tr>
					<tr><td><a href="http://www.mag2.com/j/pci/pg/03/0001.html">まぐまぐ Java</a></td></tr>
					<tr><td><a href="http://objectclub.esm.co.jp/">オブジェクト倶楽部</a></td></tr>
					<tr><td><a href="http://www.rfs.jp/sb/sql/">Smart! SQL講座</a></td></tr>
					<tr><th></th></tr>
					
					<tr><th> WWW Server  </th></tr>
					<tr><td><a href="mrtg/">NetWork Monitor</a></td></tr>
					<tr><td><a href="webalizer/">Web Server Access Log 01</a></td></tr>
					<tr><td><a href="printer/printer_IPAddress.html">Printer IP Address</a></td></tr>
				</table>
			</div>
		</div>
		
		<br>
		
		<div class="container">
			<div class="col-md-3 col-md-offset-2">
				<table class="table table-hover">
					<tr><th> KCS・その他 </th></tr>
					<tr><td><a href="http://pine-net.jp/">PINE-NET(学生ｻｲﾄ)</a></td></tr>
					<tr><td><font size="2">ID   : p2013&nbsp;</font></td></tr>
					<tr><td><font size="2">PASS : 374131104p&nbsp;</font></td></tr>
					<tr><td><a href="vod/index.html">(VOD)学習コンテンツ (New!!)</a></td></tr>
					<tr><td><a href="Syusyoku/index.html">就職活動 (New!!)</a></td></tr>
					<tr><td><a href="http://spiderman3:8080/KCSJHSS/YearAction.do">就職活動支援システム（H24卒業研究作品）</a></td></tr>
					<tr><td><a href="http://job.rikunabi.com/">リクナビ</a></td></tr>
					<tr><td><a href="http://www.scc-kk.co.jp/">株式会社SCC</a></td></tr>
					<tr><td><a href="http://www.sed.co.jp/">宇宙技術開発株式会社(SED)</a></td></tr>
					<tr><td><a href="http://www.kcsk.ac.jp/">KCS北九州校</a></td></tr>
					<tr><td><a href="http://www.kcs-f.ac.jp/">KCS福岡校</a></td></tr>
					<tr><td><a href="http://www.kcsoita.ac.jp/">KCS大分校</a></td></tr>
					<tr><td><a href="http://www.kcska.ac.jp/">KCS鹿児島校</a></td></tr>
					<tr><td><a href="http://www.do-johodai.ac.jp/">北海道情報大学</a></td></tr>
					<tr><td><a href="http://mugendai.do-johodai.ac.jp/~mugendai/menu.html">無限大キャンパス</a></td></tr>
					<tr><td><a href="http://spiderman3:8080//HIUmarathon/jsp/top.jsp">HIUマラソン（H24卒業研究作品）</a></td></tr>
				</table>
			</div>
			
			<div class="col-md-3 col-md-offset-2">
				<table class="table table-hover">
					<tr><th  align="center"> Document </th></tr>
					<tr><td><a href="jdk6docs/ja/api/index.html">jdk6</a></td></tr>
					<tr><td><a href="servletapi-4.0/docs-ja/index.html">Servlet/JSP API</a></td></tr>
					<tr><td><a href="refman-4.1-ja.html-chapter/index.html">MySQL4.1</a></td></tr>
					<tr><td><a href="refman-5.1-ja.html-chapter/index.html">MySQL5.1</a></td></tr>
					<tr><td><a href="tohoho/www.htm">とほほのWWW入門</a></td></tr>
					<tr><td><a href="http://sdc.sun.co.jp/java/docs/j2se/1.4/ja/docs/ja/guide/jdbc/getstart/GettingStartedTOC.fm.html">JDBC Note</a></td></tr>
					<tr><td><a href="http://www.atmarkit.co.jp/">@IT</a></td></tr>
					<tr><td><a href="http://www.linux.or.jp/JF/">Linux Japanese FAQ Project</a></td></tr>
					<tr><td><a href="http://docs.sun.com/?l=ja">Sunの製品文書</a></td></tr>
					<tr><td><a href="http://www-6.ibm.com/jp/developerworks/">developerWorks</a></td></tr>
					<tr><td><a href="eclipseDoc/eclipse.html">Ｅｃｌｉｐｓｅドキュメント</a></td></tr>
					<tr><td><a href="http://www.hi-ho.ne.jp/douton/index.html">色とJavaScriptで遊ぶD. project</a></td></tr>
					<tr><th></th></tr>
					<tr><th><a href="http://www.google.com/" target="_top">Google</a></th></tr>
					<!-- Google検索 -->
					<tr><th colspan=3 class="go">
					<form method="GET" action="http://www.google.com/search">
						<div class="form-group">
							<input type="hidden" name="ie" value="UTF-8">
							<input type="hidden" name="oe" value="UTF-8">
							<input type="hidden" name="hl" value="ja">
							<input type="hidden" name="lr" value="lang_ja">
							<input type="hidden" name="as_sitesearch" value="">
							<input type="text" name="q" size=28 maxlength=255 value="" class="form-control">
							を
							<input type="submit" class="btn" value="検索">
						</div>
					</form>
  					</th></tr>
				</table>
			</div>
		</div>
	</div>
	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
	<script src="https://code.jquery.com/jquery.js"></script>
	<!-- Include all compiled plugins (below), or include individual files as needed -->
	<script src="js/bootstrap.min.js"></script>
</body>
</html>